
abstract class Animal {
    abstract String cry();

    abstract String getAnimalName();
}

class Cat extends Animal {
    String name = "猫";
    String voice = "喵喵";
    Cat (){}
    Cat (String name,String vioce){
        this.name = name;
        this.voice = vioce;
    }
    String cry() {
        return voice;
    }

    String getAnimalName() {
        return name;
    }
}

class Dog extends Animal {
    String name = "狗";
    String voice = "汪汪";
    Dog(){}
    Dog (String name,String vioce){
        this.name = name;
        this.voice = vioce;
    }
    String cry() {
        return voice;
    }

    String getAnimalName() {
        return name;
    }
}

class Simulator {
    void playSound(Animal a) {
        System.out.println("动物声音：" + a.cry());
        System.err.println("动物名字：" + a.getAnimalName());
    }
}

public class lab_3 {
    public static void main(String[] args) throws Exception {
        Simulator simulator = new Simulator();
        simulator.playSound(new Dog("狗","汪汪"));
        simulator.playSound(new Cat("猫","喵喵"));
    }
}
